﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using umbraco.NodeFactory;
using SPCFMedicineInformer.Helpers;
using Vega.USiteBuilder;
using SPCFMedicineInformer.DocumentTypes;

namespace SPCFMedicineInformer.Masterpages
{
    public partial class ContentSlideshowItem : System.Web.UI.MasterPage
    {
        string slideName = string.Empty;
        protected void Page_Load(object sender, EventArgs e)
        {
            
            slideName = Request.QueryString["article"] != null ? Request.QueryString["article"].ToString() : string.Empty;
            if (!IsPostBack)
            {
                if (!string.IsNullOrEmpty(slideName))
                {
                    Node node = UmbracoNodeHelper.GetNodeByName(UmbracoNodeHelper.GetSlideshowFolder(), slideName);
                    var slide = node.NodeTypeAlias == "SlideshowItem" ? ContentHelper.GetByNodeId<SlideshowItem>(node.Id) : null;
                    if (slide != null)
                    {
                        litContent.Text = slide.Content;
                        litTitle.Text = slide.SlideTitle;
                        slideImage.ImageUrl = slide.ImageUrl;
                    }
                }
            }
            
        }
    }
}